Refer to the Lecture Notes on "Kirchoff's Laws and Nodal Analysis" https://classes.engr.oregonstate.edu/eecs/fall2023/ece580/Lecture%20Notes%202023/Kirchhoff's%20Laws%20and%20Nodal%20Analysis.pdf